<template>
  <div>
    <table class="my-table">
      <thead>
        <tr>
          <!-- <th>编号</th>
          <th>图片</th>
          <th>名称</th>
          <th width="100px">标签</th> -->
          <slot></slot>
        </tr>
      </thead>
      <tbody>
        <!-- 渲染商品  遍历数组  key取每一项的id值  有id最好用id -->
        <tr v-for="item in goods" :key="item.id">
          <div>
            <td>{{ item.id }}</td>
            <!-- 动态绑定img的src地址  动态绑定不用加{{}} -->
            <td><img :src="item.picture" /></td>
            <td>{{ item.name }}</td>
            <td>
              <!-- <MyTag :value="item.tag" @input="item.tag = $event"></MyTag> -->
              <!-- 相当于  ↓ -->
              <MyTag v-model="item.tag"></MyTag>
            </td>
          </div>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  props: {
    goods: {
      type: Array,
      default: () => [],
    },
  },
}
</script>

<style lang="less">
.my-table {
  width: 100%;
  border-spacing: 0;
  img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    vertical-align: middle;
  }
  th {
    background: #f5f5f5;
    border-bottom: 2px solid #069;
  }
  td {
    border-bottom: 1px dashed #ccc;
  }
  td,
  th {
    text-align: center;
    padding: 10px;
    transition: all 0.5s;
    &.red {
      color: red;
    }
  }
  .none {
    height: 100px;
    line-height: 100px;
    color: #999;
  }
}
</style>
